import datetime
from google.appengine.ext import ndb

class Reader(ndb.Model):
    lastrefresh = ndb.DateTimeProperty(auto_now_add=True, indexed=False)
    expanded = ndb.BooleanProperty(default=True, required=True,
                                   indexed=False)
    sidebar = ndb.BooleanProperty(default=True, required=True,
                                  indexed=False)


class Subscription(ndb.Model): # URL as key
    enabled = ndb.BooleanProperty(default=True, required=True)
    name = ndb.StringProperty(required=True)
    count = ndb.IntegerProperty(indexed=False, default=0, required=True)


class Item(ndb.Model): # guid as key
    sub = ndb.KeyProperty(kind=Subscription, required=True)
    title = ndb.StringProperty(indexed=False, required=True)
    link = ndb.StringProperty(indexed=False, required=True)
    description = ndb.TextProperty()
    time = ndb.DateTimeProperty(auto_now_add=True, required=True)
    unread = ndb.BooleanProperty(default=True, required=True)
    starred = ndb.BooleanProperty(default=False, required=True)
